package com.yimi.yinhepda.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.yimi.yinhepda.R;
import com.yimi.yinhepda.entity.bean.DispatchBackScanEntity;
import java.util.List;

/**
 * @author 000432
 * @date 2018/3/9 0009
 */

public class DispatchBackScanAdapter extends BaseAdapter {

  private List<DispatchBackScanEntity> mList;
  private Context mContext;

  public DispatchBackScanAdapter(Context context, List<DispatchBackScanEntity> list) {
    this.mContext = context;
    this.mList = list;
  }

  @Override public int getCount() {
    return mList.size();
  }

  @Override public Object getItem(int position) {
    return mList.get(position);
  }

  @Override public long getItemId(int position) {
    return position;
  }

  @Override public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;
    if (convertView == null) {
      holder = new ViewHolder();
      convertView = LayoutInflater.from(mContext).inflate(R.layout.dispatch_back_scan_item, null);
      holder.mWaybillNo = (TextView) convertView.findViewById(R.id.back_scan_item_waybillNo);
      holder.mScanNum = (TextView) convertView.findViewById(R.id.back_scan_item_scanNum);
      holder.mScanTime = (TextView) convertView.findViewById(R.id.back_scan_item_scanTime);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    DispatchBackScanEntity entity = mList.get(position);
    holder.mWaybillNo.setText(entity.getWayBillNo());
    holder.mScanNum.setText(entity.getScanNum() + "");
    holder.mScanTime.setText(entity.getScanTime());

    return convertView;
  }

  static class ViewHolder {
    private TextView mWaybillNo;
    private TextView mScanNum;
    private TextView mScanTime;
  }

  public List<DispatchBackScanEntity> getmList() {
    return mList;
  }

  public void setmList(List<DispatchBackScanEntity> mList) {
    this.mList = mList;
  }
}
